Skip to content

refactor: extract webhook submission logic into a useWebhookSubmit#7537

Open
Manishnemade12 wants to merge 16 commits intolayer5io:masterfrom
Manishnemade12:eliminate
Open

refactor: extract webhook submission logic into a useWebhookSubmit#7537
Manishnemade12 wants to merge 16 commits intolayer5io:masterfrom
Manishnemade12:eliminate

Conversation

@Manishnemade12
Copy link
Copy Markdown

@Manishnemade12 Manishnemade12 commented Mar 22, 2026

Description

This PR fixes #7536

This PR abstracts and centralizes the duplicated webhook submission logic by introducing a custom useWebhookSubmit hook. It integrates this new hook into the CommonForm (index.js and events.js) and ContactForm (index.js) components. Previously, these forms used an unhandled axios.post inside a useEffect triggered by a state flag, which risked silent data loss on network failure. By awaiting the network requests directly inside the Formik onSubmit handlers, we ensure the UI transitions to the "Thank You" screen only upon a confirmed HTTP success.

Notes for Reviewers

  • The new hook is located at src/utils/hooks/useWebhookSubmit.js.
  • This change affects /contact, /community/events, and other form pages.
  • To test locally: Submit a form and verify it proceeds to the success step. If you drop your network connection before submitting, it will correctly alert you of the failure and retain your form state instead of showing a false success.

Signed commits

  • Yes, I signed my commits.

Copilot AI review requested due to automatic review settings March 22, 2026 06:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes webhook submission logic into a new useWebhookSubmit hook and updates existing forms to await submissions in Formik’s onSubmit, preventing false-positive “success” UI transitions when requests fail.

Changes:

  • Added useWebhookSubmit hook to encapsulate axios submission state + error handling.
  • Refactored CommonForm, EventForm, and ContactForm to submit via the hook inside onSubmit (removing prior useEffect-triggered posts).
  • Added basic failure handling (alerts) and kept success scrolling behavior within the submit flow.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
src/utils/hooks/useWebhookSubmit.js Introduces a reusable hook to submit payloads to the Make.com webhook and track submission/error state.
src/components/ContactForm/index.js Switches to awaiting webhook submission in onSubmit and only transitions UI on success.
src/components/CommonForm/index.js Replaces useEffect-based post with awaited submit and gates success step on confirmed submission.
src/components/CommonForm/events.js Refactors event form submission to use the hook and handle failure explicitly.

…hook and integrate it into CommonForm and ContactForm components.

Signed-off-by: Manishnemade12 <mnemade140@gmail.com>
@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 22, 2026

🚀 Preview for commit 709d5f4 at: https://69bf9360215bccffd0afcbeb--layer5.netlify.app

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 22, 2026

🚀 Preview for commit c17fb1c at: https://69bfa8b06f2ab006b9de4b89--layer5.netlify.app

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 24, 2026

🚀 Preview for commit aeb3e68 at: https://69c1f9b6c87786311b23e0c6--layer5.netlify.app

@Manishnemade12
Copy link
Copy Markdown
Author

@CodexRaunak can you please review this pr

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 24, 2026

🚀 Preview for commit b1f5d72 at: https://69c230ab39fb22adc0c2d56b--layer5.netlify.app

@Manishnemade12
Copy link
Copy Markdown
Author

Manishnemade12 commented Mar 25, 2026

@saurabhraghuvanshii can you please review this pr

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Manish Nemade <166635137+Manishnemade12@users.noreply.github.com>
@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 25, 2026

🚀 Preview for commit 9dede11 at: https://69c3a8772f6d231371e28811--layer5.netlify.app

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 25, 2026

🚀 Preview for commit bff7508 at: https://69c3dc33a1de532588f1acdb--layer5.netlify.app

@Manishnemade12
Copy link
Copy Markdown
Author

@saurabhraghuvanshii can you please review this pr

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 26, 2026

🚀 Preview for commit 96f097d at: https://69c4cecb8748eee6140f5f36--layer5.netlify.app

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 28, 2026

🚀 Preview for commit f744db5 at: https://69c7e653c5238f112a3bf1aa--layer5.netlify.app

Signed-off-by: Manishnemade12 <mnemade140@gmail.com>
@Manishnemade12
Copy link
Copy Markdown
Author

@rishiraj38 i addressed your changes can you please review it now

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 28, 2026

🚀 Preview for commit 185c96e at: https://69c81ea05353dd80e8a52b9b--layer5.netlify.app

@Manishnemade12
Copy link
Copy Markdown
Author

@saurabhraghuvanshii can you please review this pr

@l5io
Copy link
Copy Markdown
Member

l5io commented Apr 3, 2026

🚀 Preview for commit 5b5f726 at: https://69cf571d9fc8b8195bffb68c--layer5.netlify.app

Copy link
Copy Markdown
Member

@rishiraj38 rishiraj38 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look on copilot review

@Manishnemade12
Copy link
Copy Markdown
Author

@rishiraj38 Replaced the blocking alert() on form submission failure with an inline, accessible error message using Formik status and an aria-live region. This keeps users in context, improves accessibility, and avoids disruptive browser modals.

Signed-off-by: Manishnemade12 <mnemade140@gmail.com>
@l5io
Copy link
Copy Markdown
Member

l5io commented Apr 3, 2026

🚀 Preview for commit f5f5384 at: https://69cf8a11fa0a08bd41a76430--layer5.netlify.app

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Copy link
Copy Markdown
Member

@rishiraj38 rishiraj38 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also change the alerts in these lines.

…d ContactForm

Signed-off-by: Manishnemade12 <mnemade140@gmail.com>
@Manishnemade12
Copy link
Copy Markdown
Author

@rishiraj38 i Replaced alert("Submission failed...") in both index.js and index.js with Formik setStatus + inline accessible error UI (role="alert", aria-live="assertive").
Also clear error status on successful submit (setStatus(null)) .

@rishiraj38
Copy link
Copy Markdown
Member

Please take a look at copilot suggestions.

@Manishnemade12
Copy link
Copy Markdown
Author

Please take a look at copilot suggestions.

@rishiraj38 i addressed all Copilot comments

@saurabhraghuvanshii
Copy link
Copy Markdown
Member

@Manishnemade12 Please present it tommorow meeting https://meet.layer5.io/websites-minutes

@YASHMAHAKAL YASHMAHAKAL added the issue/dco Commit sign-off instructions label Apr 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

🚨 Alert! Git Police! We couldn’t help but notice that one or more of your commits is missing a sign-off. A what? A commit sign-off (your email address).

To amend the commits in this PR with your signoff using the instructions provided in the DCO check.

To configure your dev environment to automatically signoff on your commits in the future, see these instructions.


        Be sure to join the community, if you haven't yet and please leave a ⭐ star on the project 😄

@arjunmehta-git
Copy link
Copy Markdown

This is a meaningful reliability improvement, @Manishnemade12. The core insight — that an unhandled axios.post inside a useEffect triggered by a state flag can silently succeed from the UI's perspective while the network request fails — is exactly the kind of subtle bug that's easy to miss and hard to debug in production. Moving to await-ing the request directly in Formik's onSubmit is the correct pattern.

A few things still blocking merge:

  • DCO sign-off missing — The git-police bot flagged that one or more commits lack a sign-off. Please amend those commits with git commit --amend -s (or rebase with --signoff) before this can merge. This is a hard requirement.
  • Copilot review suggestions@rishiraj38 asked you to address the Copilot review comments. Please confirm all of those are resolved and mark the conversation threads as resolved so reviewers can see the current state clearly.
  • Inline error UI — The switch from alert() to Formik status with role="alert" / aria-live="assertive" is the right call for accessibility. Good initiative on that addition.

Once the DCO is fixed and the review threads are resolved, this is close to mergeable.

…mit hook

Signed-off-by: Manishnemade12 <mnemade140@gmail.com>
Signed-off-by: Manishnemade12 <mnemade140@gmail.com>
@Manishnemade12
Copy link
Copy Markdown
Author

Manishnemade12 commented Apr 9, 2026

@rishiraj38 @arjunmehta-git i resolved all copilot comments and and dco signoff issue
so please review it whenever you get time .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

issue/dco Commit sign-off instructions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eliminate redundant, error-prone webhook posting logic that is duplicated across the application's forms

7 participants